package org.papillion39.sechelper.application.data.model;

import java.io.Serializable;
import java.util.Objects;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Jonathan Paz <jonathan.paz@ottr.com>
 */
@Entity
@Table(name = "person_address")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PersonAddress.findAll", query = "SELECT p FROM PersonAddress p"),
    @NamedQuery(name = "PersonAddress.findById", query = "SELECT p FROM PersonAddress p WHERE p.id = :id")})
public class PersonAddress implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer id;
    @Size(max = 2147483647)
    @Column(name = "address_type", length = 2147483647)
    private String addressType;
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    private boolean preferred;
    @Size(max = 2147483647)
    @Column(length = 2147483647)
    private String line1;
    @Size(max = 2147483647)
    @Column(length = 2147483647)
    private String line2;
    @Size(max = 2147483647)
    @Column(length = 2147483647)
    private String line3;
    @Size(max = 2147483647)
    @Column(length = 2147483647)
    private String city;
    @Size(max = 2147483647)
    @Column(name = "state_province", length = 2147483647)
    private String stateProvince;
    @Size(max = 2147483647)
    @Column(name = "postal_code", length = 2147483647)
    private String postalCode;
    @Size(max = 2147483647)
    @Column(length = 2147483647)
    private String county;
    @Size(max = 2147483647)
    @Column(length = 2147483647)
    private String country;
    @Column(name = "date_effective")
    @Temporal(TemporalType.DATE)
    private java.sql.Date dateEffective;
    @JoinColumn(name = "person_id", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Person personId;

    public PersonAddress() {
    }

    public PersonAddress(Integer id) {
        this.id = id;
    }

    public PersonAddress(Integer id, boolean preferred) {
        this.id = id;
        this.preferred = preferred;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getAddressType() {
        return addressType;
    }

    public void setAddressType(String addressType) {
        this.addressType = addressType;
    }

    public boolean getPreferred() {
        return preferred;
    }

    public void setPreferred(boolean preferred) {
        this.preferred = preferred;
    }

    public String getLine1() {
        return line1;
    }

    public void setLine1(String line1) {
        this.line1 = line1;
    }

    public String getLine2() {
        return line2;
    }

    public void setLine2(String line2) {
        this.line2 = line2;
    }

    public String getLine3() {
        return line3;
    }

    public void setLine3(String line3) {
        this.line3 = line3;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getStateProvince() {
        return stateProvince;
    }

    public void setStateProvince(String stateProvince) {
        this.stateProvince = stateProvince;
    }

    public String getPostalCode() {
        return postalCode;
    }

    public void setPostalCode(String postalCode) {
        this.postalCode = postalCode;
    }

    public String getCounty() {
        return county;
    }

    public void setCounty(String county) {
        this.county = county;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public java.sql.Date getDateEffective() {
        return dateEffective;
    }

    public void setDateEffective(java.sql.Date dateEffective) {
        this.dateEffective = dateEffective;
    }

    public Person getPersonId() {
        return personId;
    }

    public void setPersonId(Person personId) {
        this.personId = personId;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 53 * hash + Objects.hashCode(this.id);
        hash = 53 * hash + Objects.hashCode(this.addressType);
        hash = 53 * hash + (this.preferred ? 1 : 0);
        hash = 53 * hash + Objects.hashCode(this.line1);
        hash = 53 * hash + Objects.hashCode(this.line2);
        hash = 53 * hash + Objects.hashCode(this.line3);
        hash = 53 * hash + Objects.hashCode(this.city);
        hash = 53 * hash + Objects.hashCode(this.stateProvince);
        hash = 53 * hash + Objects.hashCode(this.postalCode);
        hash = 53 * hash + Objects.hashCode(this.county);
        hash = 53 * hash + Objects.hashCode(this.country);
        hash = 53 * hash + Objects.hashCode(this.dateEffective);
        hash = 53 * hash + Objects.hashCode(this.personId);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PersonAddress other = (PersonAddress) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        if (!Objects.equals(this.addressType, other.addressType)) {
            return false;
        }
        if (this.preferred != other.preferred) {
            return false;
        }
        if (!Objects.equals(this.line1, other.line1)) {
            return false;
        }
        if (!Objects.equals(this.line2, other.line2)) {
            return false;
        }
        if (!Objects.equals(this.line3, other.line3)) {
            return false;
        }
        if (!Objects.equals(this.city, other.city)) {
            return false;
        }
        if (!Objects.equals(this.stateProvince, other.stateProvince)) {
            return false;
        }
        if (!Objects.equals(this.postalCode, other.postalCode)) {
            return false;
        }
        if (!Objects.equals(this.county, other.county)) {
            return false;
        }
        if (!Objects.equals(this.country, other.country)) {
            return false;
        }
        if (!Objects.equals(this.dateEffective, other.dateEffective)) {
            return false;
        }
        if (!Objects.equals(this.personId, other.personId)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "PersonAddress{" + "id=" + id + ", addressType=" + addressType + ", preferred=" + preferred + ", line1=" + line1 + ", line2=" + line2 + ", line3=" + line3 + ", city=" + city + ", stateProvince=" + stateProvince + ", postalCode=" + postalCode + ", county=" + county + ", country=" + country + ", dateEffective=" + dateEffective + ", personId=" + personId + '}';
    }

}
